package com.example.flashsales.service.impl;

import com.example.flashsales.entity.pojo.TimeConfig;
import com.example.flashsales.mappers.TimeMapper;
import com.example.flashsales.service.TimeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;

@Service
public class TimeServiceImpl implements TimeService {

    @Autowired
    TimeMapper timeMapper;

    @Override
    public boolean updateTimeConfig(Date date) {
        final String format = new SimpleDateFormat("HH:mm:ss").format(date);
        return timeMapper.updateTimeConfig(format) > 0;
    }


    /**
     * 查看时间
     * @return
     */
    @Override
    public TimeConfig viewTime() {
        return timeMapper.viewTime();
    }
}
